package com.sky.user.controller;


import com.sky.user.domain.User;
import com.sky.user.domain.common.Response;
import com.sky.user.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/v1/user")
@CrossOrigin("*")
@RestController
@Slf4j
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping(value = "/query_user/{id}", method = RequestMethod.GET)
    public Response<User> queryUserById(@PathVariable("id") String id) {
        log.info("【灰度服务】查询User,by id:{}", id);
        try {
            User order = userService.queryUserById(id);
            return Response.<User>builder()
                    .code(Response.ResStatus.SUCCESS.getCode())
                    .message(Response.ResStatus.SUCCESS.getInfo())
                    .data(order)
                    .build();
        } catch (Exception e) {
            return Response.<User>builder()
                    .code(Response.ResStatus.ERROR.getCode())
                    .message(Response.ResStatus.ERROR.getInfo())
                    .build();
        }
    }
}
